@model PageEntity
@{
    Script.Reqiured("validate").AtFoot();
}

<div class="panel panel-default">
    <div class="panel-heading">
        @L("页面")
    </div>
    <div class="panel-body">
        @using (Html.BeginForm())
        {
            @Html.EditorForModel()
            <div class="toolBar">
                @if (Authorizer.Authorize(PermissionKeys.ManagePage))
                {
                    <input type="submit" class="btn btn-primary" value="@L("保存")" />
                }
                <input type="button" class="btn btn-default cancel" value="@L("取消")" />
            </div>
        }
    </div>
</div>
@using (Script.AtFoot())
{
    <script type="text/javascript">
        $(function () {
            var url = $("#Url");
            url.data("url", url.val());
        });
        $(document).on("keyup", "#PageUrl", function () {
            var url = $("#Url");
            var parentUrl = url.data("url");
            if (!parentUrl) {
                parentUrl = "~/";
            }
            var thisUrl = $(this).val().toLowerCase();
            var replaceValue = ["/", " ", "?", "`", "~", "!", "@@", "#", "$", "%", "^", "&", "*", "(", ")", "+", "[", "]", "{", "}", "\\", "|", ";", ":", "'", "\"", ",", ".", "<", ">"];
            for (var i = 0; i < replaceValue.length; i++) {
                thisUrl = thisUrl.replaceAll(replaceValue[i], "-");
            }
            $(this).val(thisUrl);
            url.val(parentUrl + thisUrl);
        });
        $("form").on("submit", function () { $("#PageUrl").trigger("keyup"); });
    </script>
}